package com.hr.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hr.entity.AoaUser;
import com.hr.mapper.AoaUserMapper;
import com.hr.service.AoaUserService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * (AoaUser)表服务实现类
 *
 * @author makejava
 * @since 2022-06-09 08:55:31
 */
@Service("aoaUserService")
//@Transactional
public class AoaUserServiceImpl extends ServiceImpl<AoaUserMapper, AoaUser> implements AoaUserService {
    @Autowired
    private AoaUserMapper aoaUserMapper;


    //分页查询用户列表
    @Override
    public Page<AoaUser> queryList(Page<AoaUser> page, String deptName) {
        page = aoaUserMapper.queryList(page,deptName);
        return page;
    }

    /**
     * 保存或修改
     * @param aoaUser
     * @return
     */
    @Override
    public boolean save(@RequestBody AoaUser aoaUser) {
        int row=0;
        if(aoaUser.getUserId() ==null){
             row = aoaUserMapper.insert(aoaUser);
        }else{
            row = aoaUserMapper.updateById(aoaUser);
        }
        return row >0;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public boolean delete(Integer id) {
        int i = aoaUserMapper.deleteById(id);
        return i>0;
    }

    /**
     * 单值查询
     * @param id
     * @return
     */
    @Override
    public AoaUser queryById(Integer id) {
        AoaUser aoaUser = aoaUserMapper.selectById(id);
        return aoaUser;
    }


}

